<?php
class Orderservice_model extends CI_Model {
		
	public function create($data){
		
        $insert = $this->db->insert('ordemservico', $data);
        if($insert){
            return $this->db->insert_id();
        } else {
            return false;
		}
    }
 
    public function update($id, $data){
        $this->db->where('id', $id);
        $update = $this->db->update('ordemservico', $data);
        return $update;
    }
 
    public function get($id = false){
        if ($id) $this->db->where('id', $id);
        $this->db->order_by('prioridade', 'desc');
		$this->db->order_by('status', 'asc');
        $get = $this->db->get('ordemservico');
 
        if($id) return $get->row_array();
        if($get->num_rows > 1) return $get->result_array();
        return array();
    }
    
	public function delete($id){
        $this->db->where('id', $id);
        $this->db->delete('ordemservico');
    }
}
